package com.xq.jltx.kotlinandroid.mmkv

import com.google.gson.reflect.TypeToken

/**
 * @author aidenquan
 *         Created by junlintianxia on 2021/11/26.
 */
object PreferenceHolder {
    inline fun <reified T : Any> bindToPreferenceField(
        default: T, key: String? = null, caching: Boolean = true
    ): MMKVDelegate<T> =
        SettingsMMKVDelegate(key, default, object : TypeToken<T>() {}.type)

    var boolVal: Boolean by bindToPreferenceField(
        true
    )

    var intVal: Int by bindToPreferenceField(
        1
    )
}